package com.hankarun.gevrek.lib;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteHelper extends SQLiteOpenHelper{
	public static final String TABLE_GROUPS = "newsgroups";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_GROUP = "groups";
	
	public static final String TABLE_MESSAGES = "messages";
	public static final String COLUMN_ID1 = "_id";
	public static final String COLUMN_MESSAGE = "message";

	private static final String DATABASE_NAME = "gevrek.db";
	private static final int DATABASE_VERSION = 1;

	private static final String DATABASE_CREATE = "create table "
			+ TABLE_GROUPS + "( " + COLUMN_ID
			+ " integer primary key autoincrement, " + COLUMN_GROUP
			+ " text not null);";
	
	private static final String DATABASE_CREATE2 = "create table "
			+ TABLE_MESSAGES + "( " + COLUMN_ID1
			+ " integer primary key autoincrement, " + COLUMN_MESSAGE
			+ " text not null);";
	
	public SQLiteHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase arg0) {
		arg0.execSQL(DATABASE_CREATE);
		arg0.execSQL(DATABASE_CREATE2);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		arg0.execSQL("DROP TABLE IF EXISTS " + TABLE_GROUPS);
		arg0.execSQL("DROP TABLE IF EXISTS " + TABLE_MESSAGES);
		onCreate(arg0);
		
	}
}
